home *** CD-ROM | disk | FTP | other *** search
/ PC Users 8 / Cd Pc Users extra 8.iso / prog / inst / firstimp / vcimpres.z / drill1.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1997-11-07  |  11.5 KB  |  303 lines

  1. VERSION 4.00
  2. Begin VB.Form Form1 
  3.    Caption         =   "First Impression Drill Down Example"
  4.    ClientHeight    =   6450
  5.    ClientLeft      =   2295
  6.    ClientTop       =   1770
  7.    ClientWidth     =   9660
  8.    Height          =   7140
  9.    Icon            =   "drill1.frx":0000
  10.    Left            =   2235
  11.    LinkTopic       =   "Form1"
  12.    ScaleHeight     =   6450
  13.    ScaleWidth      =   9660
  14.    Top             =   1140
  15.    Width           =   9780
  16.    Begin VB.Data Data1 
  17.       Caption         =   "CPU Data"
  18.       Connect         =   "Access"
  19.       DatabaseName    =   ""
  20.       Exclusive       =   0   'False
  21.       Height          =   315
  22.       Left            =   6300
  23.       Options         =   0
  24.       ReadOnly        =   0   'False
  25.       RecordsetType   =   2  'Snapshot
  26.       RecordSource    =   ""
  27.       Top             =   5760
  28.       Visible         =   0   'False
  29.       Width           =   3075
  30.    End
  31.    Begin Threed.SSPanel pnlStatus 
  32.       Align           =   2  'Align Bottom
  33.       Height          =   330
  34.       Left            =   0
  35.       TabIndex        =   0
  36.       Top             =   6120
  37.       Width           =   9660
  38.       _Version        =   65536
  39.       _ExtentX        =   17039
  40.       _ExtentY        =   582
  41.       _StockProps     =   15
  42.       Caption         =   "Ready"
  43.       BackColor       =   12632256
  44.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  45.          Name            =   "MS Sans Serif"
  46.          Size            =   8.25
  47.          Charset         =   0
  48.          Weight          =   400
  49.          Underline       =   0   'False
  50.          Italic          =   0   'False
  51.          Strikethrough   =   0   'False
  52.       EndProperty
  53.       BorderWidth     =   1
  54.       BevelInner      =   1
  55.       Alignment       =   1
  56.    End
  57.    Begin VtChartLib.VtChart VtChart1 
  58.       Height          =   5535
  59.       Left            =   120
  60.       TabIndex        =   1
  61.       Top             =   120
  62.       Width           =   8655
  63.       _ExtentX        =   15266
  64.       _ExtentY        =   9763
  65.       _0              =   $"drill1.frx":030A
  66.       _1              =   $"drill1.frx":0710
  67.       _2              =   $"drill1.frx":0B15
  68.       _3              =   $"drill1.frx":0F1A
  69.       _4              =   $"drill1.frx":131F
  70.       _5              =   $"drill1.frx":1724
  71.       _6              =   $"drill1.frx":1B29
  72.       _7              =   $"drill1.frx":1F2E
  73.       _8              =   $"drill1.frx":2333
  74.       _9              =   $"drill1.frx":2738
  75.       _10             =   $"drill1.frx":2B3D
  76.       _11             =   $"drill1.frx":2F42
  77.       _12             =   $"drill1.frx":3347
  78.       _13             =   $"drill1.frx":374C
  79.       _count          =   14
  80.       _ver            =   1
  81.    End
  82.    Begin VB.Menu mnuPreviousChart 
  83.       Caption         =   "&Previous Chart!"
  84.    End
  85. Attribute VB_Name = "Form1"
  86. Attribute VB_Creatable = False
  87. Attribute VB_Exposed = False
  88. Option Explicit
  89. Dim gChartLevel%, gVendor$
  90. Function ScaleToPercent#(value#, max&, min&)
  91. '' Scales a number fit in 0 to 100 range given the range of
  92. '' the number and the max and min of the range.
  93. '' Eg max = 48, min = 15, 48 becomes 100 and 15 becomes 100.
  94.    ScaleToPercent = (value - min) * 100 / (max - min)
  95. End Function
  96. Private Sub SetupTopLevelChart()
  97.    Dim rows%, cols%, i%, j%
  98.    '' Fetch the data for the first query and refresh
  99.    pnlStatus.Caption = " Fetching data..."
  100.    pnlStatus.Refresh
  101.    Data1.RecordSource = "ModelCountByVendor"
  102.       
  103.    Data1.Refresh
  104.    '' Move the data into the chart. First size the FI DataGrid to the
  105.    '' dataset. The first column goes in the first row of labels. The
  106.    '' second column is the single pie's values and indicates how many
  107.    '' CPUs are available from each Vendor
  108.    pnlStatus.Caption = " Formatting chart..."
  109.    pnlStatus.Refresh
  110.    '' Load the template chart
  111.    VtChart1.ReadFromFile App.Path & "\template\pie1.vtc"
  112.    VtChart1.AllowSelections = True
  113.    VtChart1.AllowSeriesSelection = True
  114.    cols = Data1.Recordset.RecordCount
  115.    VtChart1.RowCount = 1
  116.    VtChart1.ColumnCount = cols
  117.    For i = 1 To cols
  118.       VtChart1.Column = i
  119.       VtChart1.ColumnLabel = Data1.Recordset!vendor
  120.       VtChart1.DataGrid.SetData 1, i, Data1.Recordset!CountOfVendor, False
  121.       Data1.Recordset.MoveNext
  122.    Next i
  123.    pnlStatus.Caption = " Ready..."
  124.    gChartLevel = 1
  125. End Sub
  126. Private Sub SetupSecondLevelChart(vendor$)
  127.    Dim rows%, cols%, i%, j%, Series As Object
  128.    '' Set a global Vendor so we can easily back up from the level 3 chart
  129.    Let gVendor = vendor
  130.       
  131.    '' Fetch the data for the second query and refresh. This chart shows
  132.    '' Performance, Cycle Time and Cache by model for the specified Vendor.
  133.    '' Notice that a pair of double quotes in a string insert a double quote
  134.    '' in the variable.
  135.    pnlStatus.Caption = " Fetching data..."
  136.    pnlStatus.Refresh
  137.    Data1.RecordSource = "SELECT Model, [Relative Performance], Cache, " & _
  138.       "[Machine Cycle Time] FROM Specification WHERE Vendor = """ & vendor & _
  139.       """ ORDER BY [Relative Performance] DESC;"
  140.       
  141.    Data1.Refresh
  142.    '' Move the data into the chart. First size the FI DataGrid to the
  143.    '' dataset. The line chart is laid out like the datagrid
  144.    pnlStatus.Caption = " Formatting chart..."
  145.    pnlStatus.Refresh
  146.    '' Load the template chart first so Form Load looks better
  147.    VtChart1.ReadFromFile App.Path & "\template\line1.vtc"
  148.    '' Turn series selections off since we only want data point activations
  149.    VtChart1.AllowSelections = True
  150.    VtChart1.AllowSeriesSelection = False
  151.    rows = Data1.Recordset.RecordCount
  152.    '' Show markers if there is only one model since a line chart
  153.    '' can't draw a line between one point. This doesn't need to
  154.    '' be reset since the chart template will reset it.
  155.    If rows = 1 Then
  156.       For Each Series In VtChart1.Plot.SeriesCollection
  157.          Series.SeriesMarker.Show = True
  158.       Next Series
  159.    End If
  160.    VtChart1.Title = "Performance and Key Indicators for " & vendor & " Models"
  161.    VtChart1.RowCount = rows
  162.    VtChart1.ColumnCount = 3
  163.    With Data1.Recordset
  164.       For i = 1 To rows
  165.          VtChart1.Row = i
  166.          VtChart1.RowLabel = !model
  167.          VtChart1.DataGrid.SetData i, 1, ![Relative Performance], False
  168.          VtChart1.DataGrid.SetData i, 2, !cache, False
  169.          VtChart1.DataGrid.SetData i, 3, ![Machine Cycle Time], False
  170.          .MoveNext
  171.       Next i
  172.    End With
  173.    pnlStatus.Caption = " Ready..."
  174.    gChartLevel = 2
  175. End Sub
  176. Private Sub SetupThirdLevelChart(vendor$, model$)
  177.    Dim rp#, ep#, cache#, maxMem#, minMem#, maxChan#, minChan#, cycleTime#
  178.    '' Fetch the data for the third query and refresh. This chart shows
  179.    '' all specifications for the specified Vendor and model. These are
  180.    '' displayed in a radar chart where all stats are normalized to a 0-100
  181.    '' scale according to a max and min for a given parameter. This makes the
  182.    '' radar chart purely relative to the data set.
  183.    pnlStatus.Caption = " Fetching data..."
  184.    pnlStatus.Refresh
  185.    '' First get the stats for the selected model
  186.    Data1.RecordSource = "SELECT * FROM specification WHERE Vendor = """ & _
  187.       vendor & """ AND Model = """ & model & """;"
  188.    Data1.Refresh
  189.    With Data1.Recordset
  190.       rp = ![Relative Performance]
  191.       ep = ![Estimated Performance]
  192.       cache = !cache
  193.       cycleTime = ![Machine Cycle Time]
  194.       maxMem = ![Max Main Memory]
  195.       minMem = ![Min Main Memory]
  196.       maxChan = ![Max Channels]
  197.       minChan = ![Min Channels]
  198.    End With
  199.    '' Now get the max and min for all parameters for scaling this
  200.    '' models values
  201.    Data1.RecordSource = "ParameterMaxMin"
  202.    Data1.Refresh
  203.    With Data1.Recordset
  204.       rp = ScaleToPercent(rp, !MaxRP, !MinRP)
  205.       ep = ScaleToPercent(ep, !MaxEP, !MinEP)
  206.       maxMem = ScaleToPercent(maxMem, !MaxMaxMem, !MinMaxMem)
  207.       minMem = ScaleToPercent(minMem, !MaxMinMem, !MinMinMem)
  208.       maxChan = ScaleToPercent(maxChan, !MaxMaxChan, !MinMaxChan)
  209.       minChan = ScaleToPercent(minChan, !MaxMinChan, !MinMinChan)
  210.       cache = ScaleToPercent(cache, !MaxCache, !MinCache)
  211.       cycleTime = ScaleToPercent(cycleTime, !MaxCT, !MinCT)
  212.    End With
  213.    '' Move the data into the chart. First size the FI DataGrid to the
  214.    '' dataset. The line chart is laid out like the datagrid
  215.    pnlStatus.Caption = " Formatting chart..."
  216.    pnlStatus.Refresh
  217.    '' Load the template chart
  218.    VtChart1.ReadFromFile App.Path & "\template\radar1.vtc"
  219.    VtChart1.Title = "Normalized Performance Indicators for " & vendor & " " & model
  220.    VtChart1.AllowSelections = False
  221.    'Exit Sub
  222.    With VtChart1.DataGrid
  223.       .SetData 1, 1, rp, False
  224.       .SetData 2, 1, ep, False
  225.       .SetData 3, 1, maxMem, False
  226.       .SetData 4, 1, minMem, False
  227.       .SetData 5, 1, maxChan, False
  228.       .SetData 6, 1, minChan, False
  229.       .SetData 7, 1, cache, False
  230.       .SetData 8, 1, cycleTime, False
  231.    End With
  232.    pnlStatus.Caption = " Ready..."
  233.    gChartLevel = 3
  234. End Sub
  235. Private Sub Form_Load()
  236.    gChartLevel = 1
  237.    Data1.DatabaseName = App.Path & "\machine.mdb"
  238.    SetupTopLevelChart
  239. End Sub
  240. Private Sub Form_Resize()
  241.    '' Repaint is set to False to stop multiple
  242.    '' paints for a single resize event
  243.    With VtChart1
  244.       .Repaint = False
  245.       .Width = ScaleWidth
  246.       .Height = ScaleHeight - pnlStatus.Height
  247.       .Repaint = True
  248.    End With
  249. End Sub
  250. Private Sub mnuPreviousChart_Click()
  251.    Select Case gChartLevel
  252.       Case 2
  253.          SetupTopLevelChart
  254.       Case 3
  255.          SetupSecondLevelChart gVendor
  256.    End Select
  257. End Sub
  258. Private Sub VtChart1_AxisLabelSelected(AxisId As Integer, AxisIndex As Integer, labelSetIndex As Integer, LabelIndex As Integer, MouseFlags As Integer, Cancel As Integer)
  259.    Cancel = True
  260. End Sub
  261. Private Sub VtChart1_AxisSelected(AxisId As Integer, AxisIndex As Integer, MouseFlags As Integer, Cancel As Integer)
  262.    Cancel = True
  263. End Sub
  264. Private Sub VtChart1_AxisTitleSelected(AxisId As Integer, AxisIndex As Integer, MouseFlags As Integer, Cancel As Integer)
  265.    Cancel = True
  266. End Sub
  267. Private Sub VtChart1_ChartSelected(MouseFlags As Integer, Cancel As Integer)
  268.    Cancel = True
  269. End Sub
  270. Private Sub VtChart1_FootnoteSelected(MouseFlags As Integer, Cancel As Integer)
  271.    Cancel = True
  272. End Sub
  273. Private Sub VtChart1_LegendSelected(MouseFlags As Integer, Cancel As Integer)
  274.    Cancel = True
  275. End Sub
  276. Private Sub VtChart1_PlotSelected(MouseFlags As Integer, Cancel As Integer)
  277.    Cancel = True
  278. End Sub
  279. Private Sub VtChart1_PointActivated(Series As Integer, DataPoint As Integer, MouseFlags As Integer, Cancel As Integer)
  280.    Cancel = True
  281.    If gChartLevel = 2 Then
  282.       VtChart1.Row = DataPoint
  283.       SetupThirdLevelChart gVendor, VtChart1.RowLabel
  284.    End If
  285.       
  286. End Sub
  287. Private Sub VtChart1_PointLabelSelected(Series As Integer, DataPoint As Integer, MouseFlags As Integer, Cancel As Integer)
  288.    Cancel = True
  289. End Sub
  290. Private Sub VtChart1_SeriesActivated(Series As Integer, MouseFlags As Integer, Cancel As Integer)
  291.    Cancel = True
  292.    If gChartLevel = 1 Then
  293.       SetupSecondLevelChart VtChart1.Plot.SeriesCollection.Item(Series).SeriesLabel.Text
  294.    End If
  295.       
  296. End Sub
  297. Private Sub VtChart1_SeriesLabelSelected(Series As Integer, MouseFlags As Integer, Cancel As Integer)
  298.    Cancel = True
  299. End Sub
  300. Private Sub VtChart1_TitleSelected(MouseFlags As Integer, Cancel As Integer)
  301.    Cancel = True
  302. End Sub
  303.